import request from '@/hooks/request'

const Api = {
  addCard: '/platform/card/addCard', // 生成卡密
  cardNum: '/platform/card/cardNum', // 卡密数量
  cardPage: '/platform/card/cardPage', // 卡密仓库
  nbBalnce: '/platform/card/nbBalnce', // 念初余额
  nbPage: '/platform/nbBalance/nbPage', // 念币明细
  editUserBalance: '/platform/user/editUserBalance', // 添加余额
  addUserBalance: '/platform/user/addUserBalance', // 充值
}

export const addUserBalance = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.addUserBalance,
    data: parameter,
  })
}

export const addCard = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.addCard,
    data: parameter,
  })
}

export const cardNum = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('userId', parameter.userId)
  return request({
    method: 'post',
    url: Api.cardNum,
    data: formData,
  })
}

export const cardPage = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.cardPage,
    data: parameter,
  })
}

export const nbBalnce = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('userId', parameter.userId)
  return request({
    method: 'post',
    url: Api.nbBalnce,
    data: formData,
  })
}

export const nbPage = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.nbPage,
    data: parameter,
  })
}

export const editUserBalance = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.editUserBalance,
    data: parameter,
  })
}

